import request from '@/request/index'

/* 上传文章 */
export function publish(datas) {
  return request({
    method: 'post',
    url: '/article/publish',
    data: datas
  })
}

/* TODO:首页-轮播图 */
export function getBanner() {
  return request({
    method: 'get',
    url: '/index/banner',
  })
}
/* 首页-推荐文章 */
export function getIndexArticle() {
  return request({
    method: 'get',
    url: '/index/articles',

  })
}
/* TODO:推荐文章详情 */
export function detailArticle(id) {
  return request({
    method: 'get',
    url: `/article/detail/${id}`
  })
}

/* TODO:推荐-推荐文章列表 */
export function getRecomList() {
  return request({
    method: 'get',
    url: '/article/listRecommend'
  })
}

/*TODO: 社区-社区文章列表 */
export function getCommuList(typeId) {
  return request({
    method: 'get',
    url: `/article/getByType/${typeId}`,

  })
}
/*TODO: 社区-文章收藏 */
export function addCollect(articlId) {
  return request({
    method: 'post',
    url: `/collect/add/${articlId}`,
  })
}
/*TODO: 社区-取消文章收藏 */
export function delCollect(articlId) {
  return request({
    method: 'post',
    url: `/collect/del/${articlId}`,
  })
}

/*TODO: 社区-文章评论 */
export function pubComment(datas) {
  return request({
    method: 'post',
    url: '/comment/publish',
    data: datas
  })
}

/*TODO: 社区-获取评论 */
export function getComments(id) {
  return request({
    method: 'get',
    url: `/comment/article/${id}`
  })
}



/*TODO: 搜索-文章搜索 */
export function search(searchStr) {
  return request({
    method: 'get',
    url: `/article/search?title=${searchStr}`,
  })
}

/*TODO:特产-获取商品列表 */
export function goodslist() {
  return request({
    method: 'get',
    url: '/sys/goods/list',
  })
}

/*TODO:特产-获取商品列表 */
export function saveOrder(goodsList) {
  return request({
    method: 'post',
    url: '/order/buy',
    headers: {
      "Content-Type": "application/json"
    },
    data: {
      items: goodsList
    }
  })
}

/*TODO:我的发布文章 */
export function myArticle() {
  return request({
    method: 'get',
    url: '/user/myArticle',
  })
}


/*TODO:我的收藏 */
export function myCollect() {
  return request({
    method: 'get',
    url: '/user/myCollect',
  })
}

/*TODO:我的订单*/
export function myOrder() {
  return request({
    method: 'get',
    url: '/user/myOrder',
  })
}

/*TODO:删除订单*/
export function delOrder(id) {
  return request({
    method: 'delete',
    url: `/order/${id}`,
  })
}